$(function(){
	$("#pro_bycsno_datagrid").datagrid({    
	    url:'repertory_manager/allProInfo.do', 
	    loadMsg:'数据加载中···',
	    fit:'true',
	    idField:'id',
	    pagination:true,
	    checkOnSelect : true,
		selectOnCheck : true,
		fitColumns:true,//允许表格自动缩放,以适应父容器  
	    columns:[[
	    {
			field : "ck",
			checkbox : true
		}, {
			field : "id",
			hidden : true
		},     
	    {
			field:'pro_no',
			title:'商品编码',
			width:240,
			align:'center',
	    },     
	    {
			field:'pro_name',
			title:'商品名称',
			width:260,
			align:'center',
	    },    
	    {
	    	field:'customer_no',
	    	title:'客户编码',
	    	width:240,
	    	align:'center'
	     },
	     {
	    	 field:'warehouse',
	    	 title:'有效仓库',
	    	 width:200,
	    	 align:'center'
	    },{
	    	 field:'location',
	    	 title:'区位',
	    	 width:200,
	    	 align:'center'
	    },{
	    	 field:'loc_no',
	    	 title:'库位号',
	    	 width:200,
	    	 align:'center'
	    },{
	    	field:'size',
	    	title:'尺寸',
	    	width:220,
	    	align:'center',
	        formatter: function(value,row,index){
	        	return row.length+"x"+row.width+"x"+row.height;
	    }},{
	    	 field:'weight',
	    	 title:'重量',
	    	 width:200,
	    	 align:'center'
	    },
//	    {
//	    	 field:'pre_postage',
//	    	 title:'预估邮费',
//	    	 width:200,
//	    	 align:'center'
//	    },
	    {
	    	 field:'image_name',
	    	 title:'图片',
	    	 width:220,
	    	 align:'center',
	    	 formatter:function(value,row,inedex){
	    		 if(value==null || value==""){
	    			 return "未上传";
	    		 }else{
	    			 return "<a target='_blank' href="+$("input[name='filePath']").val()+value+">点击查看</a>"; 
	    		 }
	    		 
	    	 }
	    }
	    ]],
	    fitColumns:true,
	    toolbar:'#pro_info_tb'
	});  	
});	
function queryPutPro(){
	$("#pro_bycsno_datagrid").datagrid({
		queryParams: {
			customerNo: $("input[name='customerNo']").val()
		}
	});
}
function resetPutPro(){
	$("input[name='customerNo']").val("");
	queryPutPro();	
}
function putInPro(){
	var rows = $("#pro_bycsno_datagrid").datagrid('getChecked');
	if (rows && rows.length == 1) {
		   $("#put_in_dialog").dialog({    
		    title: '商品入库',    
		    width: 500,   
		    maximizable:true,
		    height: 450,    
		    closed: false,    
		    cache: false,
		    iconCls:'icon-edit',
		    href: 'repertory_manager/putInPage?id='+rows[0].id,    
		    modal: true   
		});
	} else {
		parent.$.messager.alert('提示', "请选择需要入库的一件商品！");
		$("#pro_bycsno_datagrid").datagrid('uncheckAll');
	}
}
function delPro(){
	var rows = $("#pro_bycsno_datagrid").datagrid('getChecked');
	if (rows && rows.length > 0) {
		parent.$.messager.confirm('提示', '确定删除该商品信息及该商品所对应入库商品?', function(r) {
			if (r) {
				var proNos = [];
				for ( var i = 0; i < rows.length; i++){
					proNos.push(rows[i].pro_no);
				}
				$.ajax({
					url : "repertory_manager/delProInfo.do?proNos="+proNos.join(","),
					dataType : "json",
					success : function(data) {
						if (data && data.success) {
							parent.$.messager.alert('提示', data.msg);
							$("#pro_bycsno_datagrid").datagrid('reload');
							$("#pro_bycsno_datagrid").datagrid('uncheckAll');
							if($('#tabs').tabs('exists',"按客户编号商品一览")==true){
								queryPro();
	           		   		}
						} else {
							parent.$.messager.alert('错误', data.msg);
						}
			}
		});
			}});
	} else {
		parent.$.messager.alert('提示', "请选择需要删除的商品！");
	}
}